package com.kuaiyan.sdkshell;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.RelativeLayout;

import com.kuaiyan.sdkshell.ad.GuanggaoFragmentActivity;
import com.kuaiyan.sdkshell.ad.ShareWorldActivity;
import com.wmcsk.KuaiyanSignSdk;
import com.wmcsk.interfaces.SignActivityStartListener;

public class MainActivity extends Activity {
    private RelativeLayout rlAd;
    private RelativeLayout rlSign;
    private RelativeLayout rlMenu;
    private RelativeLayout rlFrament;
    private RelativeLayout rlSelectShare;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initListener();
    }

    private void initView() {
        rlAd = (RelativeLayout) findViewById(R.id.rl_ad);
        rlAd.setVisibility(View.GONE);
        rlSign = (RelativeLayout) findViewById(R.id.rl_sign);
        rlSign.setVisibility(View.GONE);
        rlMenu = (RelativeLayout) findViewById(R.id.rl_menu);
        rlMenu.setVisibility(View.GONE);
        rlFrament = (RelativeLayout) findViewById(R.id.rl_frament);
        rlFrament.setVisibility(View.GONE);
        rlSelectShare = (RelativeLayout) findViewById(R.id.rl_SelectShare);
    }

    private void initListener(){
        rlAd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(com.kuaiyan.sdkshell.ad.MainActivity.class);
            }
        });
        rlSign.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                KuaiyanSignSdk.getInstance().startSignActivity(new Bundle(), new SignActivityStartListener() {
                    @Override
                    public void lunchSignActivityError(int i, String s, Exception e) {
                        Log.e(this.getClass().getSimpleName(),"启动失败"+i+"  "+s);
                    }

                    @Override
                    public void lunchSignActivitySuccess() {
                        Log.e(this.getClass().getSimpleName(),"启动成功");
                    }
                });
            }
        });
        rlMenu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(com.kuaiyan.sdkshell.menu.MainActivity.class);
            }
        });
        rlFrament.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(GuanggaoFragmentActivity.class);
            }
        });
        rlSelectShare.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(ShareWorldActivity.class);
            }
        });
    }

//    @Override
//    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//        super.onActivityResult(requestCode, resultCode, data);
//        Log.e("onActivityResult","requestCode"+requestCode);
//        if(requestCode==KuaiyanSelectShareSdk.SHARE_CODE){
//            Bundle bundle = data.getExtras();
//            boolean shareStatus = bundle.getBoolean("shareStatu");
//            Log.e("onActivityResult","shareStatus"+shareStatus);
//            if(shareStatus){
//                Intent intent2=new Intent(Intent.ACTION_SEND);
//                File file = new File(bundle.getString("shareUrl"));
//                Uri uri=Uri.fromFile(file);
//                intent2.putExtra(Intent.EXTRA_STREAM,uri);
//                intent2.setType("image/*");
//                startActivity(Intent.createChooser(intent2,"share"));
//            }else{
//                Log.e("onActivityResult","message"+bundle.getString("message"));
//            }
//
//        }
//    }

    public void startActivity(Class clazz){
        Intent intent = new Intent(this,clazz);
        startActivity(intent);
    }
}
